package com.example.com.daervideo.vm.fragments;

import android.content.Context;
import android.databinding.Bindable;
import android.databinding.ObservableBoolean;
import android.databinding.ObservableInt;
import android.os.Bundle;

import com.example.com.daervideo.activitys.MainActivity;
import com.example.com.daervideo.activitys.users.FansActivity;
import com.example.com.daervideo.activitys.users.InvitFriendActivity;
import com.example.com.daervideo.activitys.users.MessageActivity;
import com.example.com.daervideo.activitys.users.RenZhengActivity;
import com.example.com.daervideo.activitys.users.SettingActivity;
import com.example.com.daervideo.activitys.users.UserInfoActivity;
import com.example.com.daervideo.activitys.users.WalletActivity;
import com.example.com.daervideo.entity.FansAndFollowNum;
import com.example.com.daervideo.entity.UserData;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.utils.KLog;

import com.example.com.daervideo.BR;

/**
 * Created by i7-1 on 2018/12/3.
 */

public class UserFragmentViewModel extends BaseViewModel {

    public ObservableInt currentUser = new ObservableInt(0);
    public ObservableBoolean isAttention = new ObservableBoolean(false);
    private final MainActivity mainActivity;
    public UserData userData;
    private FansAndFollowNum fansAndFollowNum;

    public UserFragmentViewModel(Context context) {
        super(context);
        mainActivity = (MainActivity) context;
    }

    public BindingCommand goWallet = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            startActivity(WalletActivity.class);
        }
    });
    public BindingCommand setting = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            startActivity(SettingActivity.class);
        }
    });

    public BindingCommand toMessage = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            startActivity(MessageActivity.class);
        }
    });
    public BindingCommand toMyAttention = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            Bundle bundle = new Bundle();
            bundle.putInt("index", 1);//我的关注
            startActivity(FansActivity.class, bundle);
        }
    });
    public BindingCommand toMyFanse = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            Bundle bundle = new Bundle();
            bundle.putInt("index", 2);//我的粉丝
            startActivity(FansActivity.class, bundle);
        }
    });
    public BindingCommand toUser = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            Bundle bundle = new Bundle();
            bundle.putSerializable("entity", getUserData());
            startActivity(UserInfoActivity.class, bundle);
        }
    });
    public BindingCommand goInvitFriends = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            startActivity(InvitFriendActivity.class);
        }
    });
    public BindingCommand renzheng = new BindingCommand(new BindingAction() {
        @Override
        public void call() {

            startActivity(RenZhengActivity.class);
        }
    });
    public BindingCommand attentionuser = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            int currentUser = mainActivity.getCurrentUser();

        }
    });
    public BindingCommand disattentionuser = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            int currentUser = mainActivity.getCurrentUser();
        }
    });

    public void setUserType(int currentUser) {
        this.currentUser.set(currentUser);
    }

    public void setIsAttention(boolean isAttention) {
        this.isAttention.set(isAttention);
    }

    public void setUserData(UserData data) {
        this.userData = data;
        notifyPropertyChanged(BR.userData);
    }

    @Bindable
    public UserData getUserData() {
        return userData;
    }

    public void setNum(FansAndFollowNum data) {
        this.fansAndFollowNum = data;
        notifyPropertyChanged(BR.fansAndFollowNum);
    }

    @Bindable
    public FansAndFollowNum getFansAndFollowNum() {
        return fansAndFollowNum;
    }
}
